global input "Q:\dc1prhcmsas01\PU2\data - sas"
global temp "Q:\dc1prhcmsas01\PU2\temp_stata_wr"
global log "Q:\dc1prhcmsas01\PU2\Log - Stata WR"
global output "Q:\dc1prhcmsas01\PU2\data_stata_wr"
global graphs "Q:\dc1prhcmsas01\PU2\graphs_stata_wr"
global tables "Q:\dc1prhcmsas01\PU2\tables_stata_wr"

cd "Q:\dc1prhcmsas01\PU2\Code - Stata WR"
set scheme plotplain
graph set window fontface "Times New Roman"

capture log close
log using "$log/11_plot_did_hires", replace

*Program to estimate regressions
cap program drop plot_est
program define plot_est 
args var name ytitle ylabel

	*Save estimates
	use "$output/`name'_estimates.dta", clear
	keep if spec=="Basic"
	
	*Label each month for graph
	label define time_lab -12 "May 2015" -11 "Jun 2015" -10 "Jul 2015" -9 "Aug 2015" -8 "Sep 2015" -7 "Oct 2015" ///
		-6 "Nov 2015" -5 "Dec 2015" -4 "Jan 2016" -3 "Feb 2016" -2 "Mar 2016" -1 "Apr 2016" ///
		0 "May 2016" 1 "Jun 2016" 2 "Jul 2016" 3 "Aug 2016" 4 "Sep 2016" 5 "Oct 2016" 6 ///
		"Nov 2016" 7 "Dec 2016" 8 "Jan 2017" 9 "Feb 2017" 10 "Mar 2017" 11 "Apr 2017" ///
		12 "May 2017" 13 "Jun 2017" 14 "Jul 2017" 15 "Aug 2017" 16 "Sep 2017" 17 "Oct 2017" ///
		18 "Nov 2017" 19 "Dec 2017" 20 "Jan 2018" 21 "Feb 2018" 22 "Mar 2018" 23 "Apr 2018" ///
		24 "May 2018", replace
	label values event_time time_lab 
	
	sum event_time 
	*Plot estimates
	graph twoway (connect beta event_time, lc(black) mcolor(black) legend(off)) (rcap ub lb event_time, color(black) legend(off)) , ///
		xline(0 7) xtitle("Month") xlabel(-12(3)`r(max)', valuelabel angle(45)) ///
		yline(0) ytitle(`ytitle') ylabel(`ylabel') legend(off)
	graph export "$graphs/`name'.eps", replace
	graph export "$graphs/`name'.jpg", replace	
end 

	
****************************************
*Plots based on Dec 2016 Characteristics
****************************************
*Fig 7a - Past job
	plot_est base fig7_base "Weekly Base Pay at Previous Job" -100(50)50
	plot_est log_base fig7_log_base "Log Weekly Base Pay at Previous Job" -0.1(0.02)0.04
	plot_est diff_base figA5_diff_base "Change in Weekly Base Pay from Previous Job" -0.1(0.05)0.2
	plot_est ot fig7_ot "Weekly Overtime Pay at Previous Job"
	plot_est salaried fig7_salaried "Salaried Status at Previous Job"
	plot_est months_diff fig7_months "Number of Months Since Last Observed Job"
	plot_est observe fig7_observe "Probability Observe Any Previous Job"
	
	*Repeat for last observed salary within 6 months
	plot_est base fig7_base_recent "Weekly Base Pay at Previous Job" 
	plot_est log_base fig7_log_base_recent "Log Weekly Base Pay at Previous Job" -0.1(0.02)0.06
	plot_est diff_base figA5_diff_base_recent "Change in Weekly Base Pay from Previous Job" -0.1(0.05)0.2
	plot_est ot fig7_ot_recent "Weekly Overtime Pay at Previous Job"
	plot_est salaried fig7_salaried_recent "Salaried Status at Previous Job"
	plot_est months_diff fig7_months_recent "Number of Months Since Last Observed Job"
	plot_est observe fig7_observe_recent "Probability Observe Any Previous Job"
	
	*Repeat at monthly frequency
	plot_est base fig7_base_monthly "Weekly Base Pay at Previous Job"
	plot_est log_base fig7_log_base_monthly "Log Weekly Base Pay at Previous Job"
	plot_est diff_base figA5_diff_base_monthly "Change in Weekly Base Pay from Previous Job"
	plot_est ot fig7_ot_monthly -12 23 1 "Weekly Overtime Pay at Previous Job"
	plot_est salaried fig7_salaried_monthly "Salaried Status at Previous Job"
	plot_est months_diff fig7_months_monthly "Number of Months Since Last Observed Job"
	plot_est observe fig7_observe_monthly "Probability Observe Any Previous Job"
	
	*Repeat using 0 for missing (i.e. assume missing means unemployed)
	plot_est base fig7_base_fill_zeros "Weekly Base Pay at Previous Job (0 if missing)"
	
*Fig 7b - Future pay (same job)
	plot_est base fig7b_base_future "Weekly Base Pay 18 Months After Hire" -100(50)50
	plot_est log_base fig7b_log_base_future "Log Weekly Base Pay 18 Months After Hire" -0.1(0.02)0.04
	plot_est wage_growth fig7b_wage_growth "Change in Weekly Base Pay 18 Months After Hire" -0.1(0.05)0.2
	plot_est ot fig7b_ot "Weekly Overtime Pay 18 Months After Hire"
	plot_est salaried fig7b_salaried "Salaried Status 18 Months After Hire"
	plot_est observe_future fig7b_observe_future "Probability in Same Job 18 Months After Hire"
	
	*Repeat using zeros for missing wages 
	plot_est base fig7b_base_future_zeros "Weekly Base Pay 18 Months After Hire" -100(50)50
	plot_est log_base fig7b_log_base_future_zeros "Log Weekly Base Pay 18 Months After Hire" -0.1(0.02)0.04
	plot_est wage_growth fig7b_wage_growth_zeros "Change in Weekly Base Pay 18 Months After Hire" -0.1(0.05)0.2
	
	*Repeat using monthly frequency
	plot_est base fig7b_base_future_month "Weekly Base Pay 18 Months After Hire"
	plot_est log_base fig7b_log_base_future_month "Log Weekly Base Pay 18 Months After Hire" -0.1(0.02)0.04
	plot_est wage_growth fig7b_wage_growth_month "Change in Weekly Base Pay 18 Months After Hire"
	plot_est ot fig7b_ot_month "Weekly Overtime Pay 18 Months After Hire"
	plot_est salaried fig7b_salaried_month "Salaried Status 18 Months After Hire"
	plot_est observe_future fig7b_observe_future_month "Probability in Same Job 18 Months After Hire"
	
*Balanced panel
	plot_est base fig7_base_balanced "Weekly Base Pay at Previous Job" -150(50)50
	plot_est log_base fig7_log_base_balanced "Log Weekly Base Pay at Previous Job" -0.1(0.02)0.04
	plot_est diff_base figA5_diff_base_balanced "Change in Weekly Base Pay from Previous Job" -0.1(0.05)0.2
	plot_est base_future fig7b_base_future_balanced "Weekly Base Pay 18 Months After Hire" -150(50)50
	plot_est log_base_future fig7b_log_base_future_balanced "Log Weekly Base Pay 18 Months After Hire" -0.1(0.02)0.04
	plot_est wage_growth fig7b_wage_growth_balanced "Change in Weekly Base Pay 18 Months After Hire" -0.1(0.05)0.2
	
	
log close